<?php
namespace app\system\model;

use think\Model;

class GroupLinkModel extends Model
{
    protected $table='__GROUP_LINK__';
    public function getGroupLinkFieldList(array $where=[], $field)
    {
        return $this->where($where)->column($field);
    }

    /**
     * @param array $where
     * @param string $fields
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function findGroupLink(array $where=[], $fields='')
    {
        $result = $this->where($where)->field($fields)->find();
        $result = !empty($result) ? $result->toArray() : $result;
        return $result;
    }

    /**
     * @param array $where
     * @param bool $order
     * @param array $fields
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function selectGroupLink(array $where=[], $order=false, $fields=[])
    {
        return $this->where($where)->order($order)->field($fields)->select();
    }

    public function addGroupLink(array $datas) {
        return $this->insertAll($datas);
    }

    public function deleteGroupLink(array $where=[])
    {
        return $this->where($where)->delete();
    }

    public function columnGroupLink($field, array $where)
    {
        return $this->where($where)->column($field);
    }

    public function countGroupLink(array $where)
    {
        return $this->where($where)->count();
    }
}